package cn.iocoder.yudao.module.business.dal.mysql.project;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.business.dal.dataobject.project.ProjectDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.business.controller.admin.project.vo.*;

/**
 * 项目 Mapper
 *
 * @author chenjiancong
 */
@Mapper
public interface ProjectMapper extends BaseMapperX<ProjectDO> {

    default PageResult<ProjectDO> selectPage(ProjectPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProjectDO>()
                .likeIfPresent(ProjectDO::getProjectName, reqVO.getProjectName())
                .eqIfPresent(ProjectDO::getYear, reqVO.getYear())
                .eqIfPresent(ProjectDO::getDeptId, reqVO.getDeptId())
                .likeIfPresent(ProjectDO::getDeptName, reqVO.getDeptName())
                .eqIfPresent(ProjectDO::getProjectType, reqVO.getProjectType())
                .eqIfPresent(ProjectDO::getProjectAttribute, reqVO.getProjectAttribute())
                .eqIfPresent(ProjectDO::getProvince, reqVO.getProvince())
                .eqIfPresent(ProjectDO::getCity, reqVO.getCity())
                .eqIfPresent(ProjectDO::getDistrict, reqVO.getDistrict())
                .eqIfPresent(ProjectDO::getArea, reqVO.getArea())
                .betweenIfPresent(ProjectDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(ProjectDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(ProjectDO::getState, reqVO.getState())
                .eqIfPresent(ProjectDO::getSubject, reqVO.getSubject())
                .eqIfPresent(ProjectDO::getTrainee, reqVO.getTrainee())
                .eqIfPresent(ProjectDO::getCoverUrl, reqVO.getCoverUrl())
                .betweenIfPresent(ProjectDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ProjectDO::getProjectTypeSecond, reqVO.getProjectTypeSecond())
                .eqIfPresent(ProjectDO::getProjectClient, reqVO.getProjectClient())
                .eqIfPresent(ProjectDO::getProjectCycle, reqVO.getProjectCycle())
                .eqIfPresent(ProjectDO::getProjectDuration, reqVO.getProjectDuration())
                .eqIfPresent(ProjectDO::getTrainDay, reqVO.getTrainDay())
                .betweenIfPresent(ProjectDO::getTrainPersonTime, reqVO.getTrainPersonTime())
                .orderByDesc(ProjectDO::getId));
    }

}